/***************************************
 *File name: MainFace.c                *
 *Author: Gu Zhengxiong                *
 *Version: 2013.11.23.1                *
 *Description:The file implements      *
 *functions in MainFace.h.             *
 ***************************************/

# include <stdio.h>//For printf ().
# include <stdlib.h>//For system (), exit (), EXIT_FAILURE.

# include "MainFace.h"

void
SetCmdProperty (void)
{
	system ("cls");
	system ("color a");
}
void
ShowFace (void)
{
	SetCmdProperty ();
	printf ("                  * * * * * * * * * * * * * * * * * * * * *\n");//18 blanks
	printf ("                  * STUDENT INFO &GRADE MANAGEMENT SYSTEM *\n");//18 blanks
	printf ("                  * * * * * * * *           * * * * * * * *\n");//18 blanks
	printf ("                                * MAIN MENU *\n");
	printf ("                                * * * * * * *\n\n");
	printf ("      * * * * * * *             * * * * * * *             * * * * * * *\n");//6 blanks
	printf ("      * 1  LOAD   *             * 2   ADD   *             * 3  SEARCH *\n");
	printf ("      * * * * * * *             * * * * * * *             * * * * * * *\n\n");
	printf ("      * * * * * * *             * * * * * * *             * * * * * * *\n");
	printf ("      * 4  MODIFY *             * 5 DISPLAY *             * 6  SORT   *\n");
	printf ("      * * * * * * *             * * * * * * *             * * * * * * *\n\n");
	printf ("      * * * * * * *             * * * * * * *             * * * * * * *\n");
	printf ("      * 7  DELETE *             * 8  SAVE   *             * 9  QUIT   *\n");
	printf ("      * * * * * * *             * * * * * * *             * * * * * * *\n\n");
}
void
ShowError (int error_type)
{
	switch (error_type)
	{
	case IN_ERR: 
		{
			printf ("\n      INPUTS ERROR!\n");
			Enter2Retn ();
		}
		break;
		case MAL_ERR: 
			{
				printf ("\n      MEMORY ALLOCATION FAILED!\n      \nPRESS ENTER TO QUIT....");
				getchar ();
				getchar ();
				exit (EXIT_FAILURE);
			}
			break;
		case UNFOUND:
			{
				printf ("\n      NOT FOUND!\n");
				//Enter2Retn ();
				printf ("\n      PRESS ENTER TO RETURN....");
				getchar ();
			}
			break;
		case NO_RECORD:
			{
				printf ("\n      THERE ARE NO RECORD NOW!\n      LOAD SOME OR ADD ONE.\n");
				Enter2Retn ();
			}
			break;
		case EXISTED:
			{
				printf ("\n      THIS RECORD ALREADY EXISTED!\n      INPUT ANOTHER ONE.\n");
				//Enter2Retn ();
				printf ("\n      PRESS ENTER TO RETURN....");
				getchar ();
			}
			break;
	}
}
void
ShowSubMenu (int menu_type)
{
	switch (menu_type)
	{
	 case MENU_ADD: ; break;
	 case MENU_MOD: 
		 {
			SetCmdProperty ();
			printf ("                  * * * * * * * * * * * * * * * * * * * * *\n");//18 blanks
			printf ("                  * STUDENT INFO &GRADE MANAGEMENT SYSTEM *\n");//18 blanks
			printf ("                  * * * * * * * *           * * * * * * * *\n");//18 blanks
			printf ("                                * SUB  MENU *\n");
			printf ("                                * * * * * * *\n\n");
			printf ("      MODIFY STUDENTS' RECORD\n\n");
			printf ("      INPUT 1 TO MODIFY STUDENTS' INFO\n      INPUT 2 TO CHANGE STUDENTS'GRADE\n");
			printf ("\n      ENTER A NUMBER: ");
		 }
		 break;
	 case MENU_DISP: 
		 {
			SetCmdProperty ();
			printf ("                  * * * * * * * * * * * * * * * * * * * * *\n");//18 blanks
			printf ("                  * STUDENT INFO &GRADE MANAGEMENT SYSTEM *\n");//18 blanks
			printf ("                  * * * * * * * *           * * * * * * * *\n");//18 blanks
			printf ("                                * SUB  MENU *\n");
			printf ("                                * * * * * * *\n\n");
			printf ("      DISPLAY STUDENTS' RECORD\n\n");
			printf ("      INPUT 1 TO DISPLAY ALL STUDENTS' INFO\n      INPUT 2 TO SHOW ALL STUDENTS'GRADE\n");
			printf ("\n      ENTER A NUMBER: ");
		 }
		 break;
	}
}
void
Enter2Retn (void)
{
	printf ("\n      PRESS ENTER TO RETURN....");
	getchar ();
	getchar ();
}
void
Enter2Retn1 (void)
{
	printf ("\n      PRESS ENTER TO RETURN....");
	getchar ();
}